#include <stdio.h>
#include <string.h>

#include <zlib.h>


#define 	BUFSIZE 	5000
#define     TESTSTR     "hello zlib!!"

// #define Z_NO_FLUSH      0
// #define Z_PARTIAL_FLUSH 1
// #define Z_SYNC_FLUSH    2
// #define Z_FULL_FLUSH    3
// #define Z_FINISH        4
// #define Z_BLOCK         5
// #define Z_TREES         6

// #define Z_OK            0
// #define Z_STREAM_END    1
// #define Z_NEED_DICT     2
// #define Z_ERRNO        (-1)
// #define Z_STREAM_ERROR (-2)
// #define Z_DATA_ERROR   (-3)
// #define Z_MEM_ERROR    (-4)
// #define Z_BUF_ERROR    (-5)
// #define Z_VERSION_ERROR (-6)

// #define Z_NO_COMPRESSION         0
// #define Z_BEST_SPEED             1
// #define Z_BEST_COMPRESSION       9
// #define Z_DEFAULT_COMPRESSION  (-1)

// #define Z_FILTERED            1
// #define Z_HUFFMAN_ONLY        2
// #define Z_RLE                 3
// #define Z_FIXED               4
// #define Z_DEFAULT_STRATEGY    0

// #define Z_BINARY   0
// #define Z_TEXT     1
// #define Z_ASCII    Z_TEXT   /* for compatibility with 1.2.2 and earlier */
// #define Z_UNKNOWN  2

// #define Z_DEFLATED   8

// #define Z_NULL  0

// int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
// int compress2 (Bytef *dest, uLongf *destLen,const Bytef *source, uLong sourceLen,int level);
// int uncompress (Bytef *dest, uLongf *destLen,const Bytef *source, uLong sourceLen);

int main( int argc, char* argv[] )
{
	int 		ret;
	int 		err;
	int 		t1,t2;
	long 		s_size;
	long 		d_size;
    long        un_size;
	char 		s_str[BUFSIZE];
	char 		d_str[BUFSIZE];
    char        un_str[BUFSIZE];


    memset( s_str, 0, strlen( s_str ) );
	memset( d_str, 0, strlen( d_str ) );
    memset( un_str, 0, strlen( un_str ) );

    // s_str
	strcpy( s_str, TESTSTR );
	s_size = strlen( s_str );
	d_size = sizeof( d_str );

	printf( "s_size : %d\n", s_size );

	// 圧縮
	ret = compress ((Bytef*)d_str, &d_size, (Bytef*)s_str, s_size );

	printf( "ret : %d\n", ret );
	printf( "d_size : %d\n", d_size );

	// 解凍
	un_size = sizeof( un_str );
	ret = uncompress ((Bytef*)un_str, &un_size, (Bytef*)d_str, d_size);

	printf( "ret : %d\n", ret );
	printf( "un_size : %d\n", un_size );

	printf( "uncompress: %s\n", un_str );

    return 0;
}